﻿using System;
using System.Windows.Forms;
using HRM.HRMServiceProxy;
using WeifenLuo.WinFormsUI.Docking;

namespace HRM
{
    public partial class frmEvaluationList : DockContent
    {

        UserClient _wcfUser;
        EvaluationCriteriaClient _wcfEvaluation;
        EvaluationCriteriaInfo _EvalInfo;
        EmployeeClient _wcfEmployee;       

        public frmEvaluationList()
        {
            InitializeComponent();
            this.KeyPreview = true;
            _wcfUser = Service.User();
            _wcfEvaluation = Service.EvaluationCriteria();
            _EvalInfo = new EvaluationCriteriaInfo();
            _wcfEmployee = Service.Employee();         
            
            dgvList.RowHeadersVisible = false;
            dgvList.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

        }

        //private void PageIndex()
        //{
        //    totalPage = itemCount % pageSize > 0 ? (itemCount / pageSize) + 1 : (itemCount / pageSize);
        //    if (totalPage == 0)
        //        lblPageIndex.Text = "0" + "/" + totalPage.ToString();
        //    else
        //        lblPageIndex.Text = (currPage + 1).ToString() + "/" + totalPage.ToString();
        //}

        //private void BuildVoucherGrid()
        //{
        //    UISetting.AddColumn(ref dgvList, "Evaluation_ID", "Mã chính", "", 1, false, true);
        //    UISetting.AddColumn(ref dgvList, "RowNumber", UpdateUI.GetString("stt"), "C", 50, true, true);
        //    UISetting.AddColumn(ref dgvList, "FullName", UpdateUI.GetString("hovaten"), "", 120, true, true);
        //    UISetting.AddColumn(ref dgvList, "Evaluation_Name", UpdateUI.GetString("khoadaotao"), "", 130, true, true);
        //    UISetting.AddColumn(ref dgvList, "Evaluation_Kind", UpdateUI.GetString("loaihinhdaotao"), "", 130, true, true);
        //    UISetting.AddColumn(ref dgvList, "Evaluation_Major", UpdateUI.GetString("chuyennganh"), "", 130, true, true);
        //    UISetting.AddColumn(ref dgvList, "Evaluation_Foreign", UpdateUI.GetString("nuocngoai"), "", 120, true, true);
        //    UISetting.AddColumn(ref dgvList, "Evaluation_Place", UpdateUI.GetString("noihoc"), "", 120, true, true);
        //    UISetting.AddColumn(ref dgvList, "Evaluation_FromDate", UpdateUI.GetString("ngaybatdau"), "", 120, true, true);
        //    UISetting.AddColumn(ref dgvList, "Evaluation_Time", UpdateUI.GetString("thoigian"), "", 120, true, true);
        //    UISetting.AddColumn(ref dgvList, "Evaluation_DateIssue", UpdateUI.GetString("ngaycap"), "", 120, true, true);
        //    UISetting.AddColumn(ref dgvList, "Evaluation_AuthorIssue", UpdateUI.GetString("noicap"), "", 120, true, true);
        //    UISetting.AddColumn(ref dgvList, "Evaluation_Rank", UpdateUI.GetString("xeploai"), "", 120, true, true);
        //    UISetting.AddColumn(ref dgvList, "Evaluation_Description", UpdateUI.GetString("ghichu"), "", 160, true, true);
        //}
        //private void LoadData()
        //{
        //    //int _month = Convert.ToInt32(cboMonth.ComboBox.SelectedValue);
        //    //int _year = Convert.ToInt32(cboYear.Text);

        //    DataSet _ds = _wcfEvaluation.Evaluation_GetList(out itemCount, currPage, pageSize, branch_ID, department_ID, _month, _year);
        //    PageIndex();
        //    dgvList.Rows.Clear();
        //    for (int i = 0; i < _ds.Tables[0].Rows.Count; i++)
        //    {
        //        dgvList.Rows.Insert(i, 1);
        //        dgvList.Rows[i].Cells["Evaluation_ID"].Value = _ds.Tables[0].Rows[i]["Evaluation_ID"].ToString();
        //        dgvList.Rows[i].Cells["RowNumber"].Value = _ds.Tables[0].Rows[i]["RowNumber"].ToString();
        //        dgvList.Rows[i].Cells["FullName"].Value = _ds.Tables[0].Rows[i]["Employee_LastName"].ToString() +
        //            " " + _ds.Tables[0].Rows[i]["Employee_FirstName"].ToString();
        //        dgvList.Rows[i].Cells["Evaluation_Name"].Value = _ds.Tables[0].Rows[i]["Evaluation_Name"].ToString();
        //        dgvList.Rows[i].Cells["Evaluation_Kind"].Value = _ds.Tables[0].Rows[i]["Evaluation_Kind"].ToString();
        //        dgvList.Rows[i].Cells["Evaluation_Major"].Value = _ds.Tables[0].Rows[i]["Evaluation_Major"].ToString();
        //        if (Convert.ToBoolean(_ds.Tables[0].Rows[i]["Evaluation_Foreign"]))
        //            dgvList.Rows[i].Cells["Evaluation_Foreign"].Value = "Nước ngoài";
        //        else
        //            dgvList.Rows[i].Cells["Evaluation_Foreign"].Value = "Trong nước";
        //        dgvList.Rows[i].Cells["Evaluation_Place"].Value = _ds.Tables[0].Rows[i]["Evaluation_Place"].ToString();
        //        dgvList.Rows[i].Cells["Evaluation_FromDate"].Value = Convert.ToDateTime(_ds.Tables[0].Rows[i]["Evaluation_FromDate"]).ToString("dd/MM/yyyy");
        //        dgvList.Rows[i].Cells["Evaluation_Time"].Value = _ds.Tables[0].Rows[i]["Evaluation_Time"].ToString();
        //        if (_ds.Tables[0].Rows[i]["Evaluation_DateIssue"] != DBNull.Value)
        //            dgvList.Rows[i].Cells["Evaluation_DateIssue"].Value = Convert.ToDateTime(_ds.Tables[0].Rows[i]["Evaluation_DateIssue"]).ToString("dd/MM/yyyy");
        //        dgvList.Rows[i].Cells["Evaluation_AuthorIssue"].Value = _ds.Tables[0].Rows[i]["Evaluation_AuthorIssue"].ToString();
        //        dgvList.Rows[i].Cells["Evaluation_Rank"].Value = _ds.Tables[0].Rows[i]["Evaluation_Rank"].ToString();
        //        dgvList.Rows[i].Cells["Evaluation_Description"].Value = _ds.Tables[0].Rows[i]["Evaluation_Description"].ToString();
        //    }
        //}



        //private void btnNew_Click(object sender, EventArgs e)
        //{
        //    if (!listRole.Create)
        //    {
        //        MessageBox.Show(UpdateUI.GetString("khongcoquyenthemmoi"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
        //        return;
        //    }
        //    Form f = new frmEvaluationInfo(0, listRole);
        //    if (f.ShowDialog(this) == DialogResult.OK)
        //    {
        //        LoadData();
        //    }
        //}

        //private void btnEdit_Click(object sender, EventArgs e)
        //{
        //    if (dgvList.SelectedRows.Count > 0)
        //    {
        //        if (listRole.Update || listRole.View)
        //        {
        //            _EvaluationID = Convert.ToInt32(dgvList.CurrentRow.Cells["Evaluation_ID"].Value);
        //            Form f = new frmEvaluationInfo(_EvaluationID, listRole);
        //            if (f.ShowDialog(this) == DialogResult.OK)
        //            {
        //                LoadData();
        //            }
        //        }
        //        else
        //            MessageBox.Show(UpdateUI.GetString("khongcoquyenxem"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
        //    }
        //}

        //private void btnDel_Click(object sender, EventArgs e)
        //{
        //    if (dgvList.SelectedRows.Count > 0)
        //    {
        //        if (!listRole.Delete)
        //        {
        //            MessageBox.Show(UpdateUI.GetString("khongcoquyenxoa"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
        //            return;
        //        }
        //        _EvaluationID = Convert.ToInt32(dgvList.CurrentRow.Cells["Evaluation_ID"].Value);
        //        if (MessageBox.Show(UpdateUI.GetString("bancochacchanxoa"), UIParamater.TitleProject, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
        //        {
        //            if (_wcfEvaluation.Evaluation_Delete(_EvaluationID))
        //            {
        //                Program.taskbarNotifier.Show(UIParamater.TitleProject, UpdateUI.GetString("xoathanhcong"), UIParamater.TIME_MOVE_UP, UIParamater.TIME_SHOW, UIParamater.TIME_MOVE_DOWN);
        //                LoadData();
        //            }
        //            else
        //            {
        //                MessageBox.Show(UpdateUI.GetString("xoakhongthanhcong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
        //            }
        //        }
        //    }
        //}

        //private void btnFisrt_Click(object sender, EventArgs e)
        //{
        //    currPage = 0;
        //    LoadData();
        //}

        //private void btnNext_Click(object sender, EventArgs e)
        //{
        //    totalPage = itemCount % pageSize > 0 ? (itemCount / pageSize) + 1 : (itemCount / pageSize);
        //    if (totalPage > 0 && currPage != totalPage - 1)
        //        currPage++;
        //    LoadData();
        //}

        //private void btnPrevious_Click(object sender, EventArgs e)
        //{
        //    if (currPage != 0)
        //        currPage--;
        //    LoadData();
        //}

        //private void btnLast_Click(object sender, EventArgs e)
        //{
        //    totalPage = itemCount % pageSize > 0 ? (itemCount / pageSize) + 1 : (itemCount / pageSize);
        //    if (totalPage != 0)
        //        currPage = totalPage - 1;
        //    LoadData();
        //}

        //private void dgvList_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        //{
        //    if (e.RowIndex >= 0)
        //        btnEdit_Click(null, null);
        //}

        //private void frmEvaluationList_KeyUp(object sender, KeyEventArgs e)
        //{
        //    switch (e.KeyCode)
        //    {
        //        case Keys.Escape:
        //            this.Dispose();
        //            this.Close();
        //            break;
        //        case Keys.F2:
        //            btnNew_Click(null, null);
        //            break;
        //        case Keys.F3:
        //            btnEdit_Click(null, null);
        //            break;
        //        case Keys.Delete:
        //            btnDel_Click(null, null);
        //            break;
        //    }
        //}

        //private void tvBranch_AfterSelect(object sender, TreeViewEventArgs e)
        //{
        //    // txtKeyWord.Text = "";
        //    if (e.Node.Level == 0)
        //    {
        //        branch_ID = 0;
        //        department_ID = 0;
        //        LoadData();
        //    }
        //    else if (e.Node.Level == 1)
        //    {
        //        branch_ID = Convert.ToInt32(e.Node.Tag);
        //        department_ID = 0;
        //        currPage = 0;
        //        LoadData();
        //    }
        //    else if (e.Node.Level == 2)
        //    {
        //        department_ID = Convert.ToInt32(e.Node.Tag);
        //        string _sql = "Select Department_BranchID from Hrm_Department where Department_ID = " + department_ID.ToString();
        //        DataTable dt = wcfMain.Query(_sql).Tables[0];
        //        branch_ID = Convert.ToInt32(dt.Rows[0]["Department_BranchID"]);
        //        currPage = 0;
        //        LoadData();

        //    }
        //}

        //private void cboYear_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    currPage = 0;
        //    LoadData();
        //}

        //private void cboMonth_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    currPage = 0;
        //    LoadData();
        //}

        //private void frmEvaluationList_Activated(object sender, EventArgs e)
        //{
        //    LoadLanguage();
        //    dgvList.Columns["RowNumber"].HeaderText = UpdateUI.GetString("stt");
        //    dgvList.Columns["FullName"].HeaderText = UpdateUI.GetString("hovaten");
        //    dgvList.Columns["Evaluation_Name"].HeaderText = UpdateUI.GetString("khoadaotao");
        //    dgvList.Columns["Evaluation_Kind"].HeaderText = UpdateUI.GetString("loaihinhdaotao");
        //    dgvList.Columns["Evaluation_Major"].HeaderText = UpdateUI.GetString("chuyennganh");
        //    dgvList.Columns["Evaluation_Foreign"].HeaderText = UpdateUI.GetString("nuocngoai");
        //    dgvList.Columns["Evaluation_Place"].HeaderText = UpdateUI.GetString("noihoc");
        //    dgvList.Columns["Evaluation_FromDate"].HeaderText = UpdateUI.GetString("ngaybatdau");
        //    dgvList.Columns["Evaluation_Time"].HeaderText = UpdateUI.GetString("thoigian");
        //    dgvList.Columns["Evaluation_DateIssue"].HeaderText = UpdateUI.GetString("ngaycap");
        //    dgvList.Columns["Evaluation_AuthorIssue"].HeaderText = UpdateUI.GetString("noicap");
        //    dgvList.Columns["Evaluation_Rank"].HeaderText = UpdateUI.GetString("xeploai");
        //    dgvList.Columns["Evaluation_Description"].HeaderText = UpdateUI.GetString("ghichu");
        //}

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}